import 'dart:core';
import 'package:event_bus/event_bus.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:unt/About.dart';
import 'package:unt/Intentpage.dart';
import 'package:unt/RowDemo.dart';

//eventbus的使用1。创建全局对象
final eventBus = EventBus();

void main() {
  runApp(
    MaterialApp(home: TextHomePage()),
  );
}

class TextHomePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return TextHomePageState();
  }
}

class TextHomePageState extends State<TextHomePage> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        routes: {
          //路由表
          "/about":(ctx)=>Yjhabout()
        },
        home: Scaffold(
            appBar: AppBar(
              title: const Text("listview"),
            ),
            body: const Center(child: yjhPage())));
  }
}

class yjhPage extends StatelessWidget {
  const yjhPage({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          child: RaisedButton(
            child: Text("Intent"),
            onPressed: () {
              _jumptopage(context);
            },
          ),
        ),
        Container(
          child: RaisedButton(
            child: Text("跳转到about"),
            onPressed: () {
              _jumpabout(context);
            },
          ),
        ),
      ],
    );
  }
}

//普通跳转玩法
void _jumptopage(BuildContext context) {
  Future res = Navigator.of(context).push(MaterialPageRoute(builder: (ctx) {
    return Intentpage("首页数据为111");
  }));
  res.then((value) => print(value.toString()));
}
void _jumpabout(BuildContext context){
  Navigator.of(context).pushNamed("/about");
}